package library.tree;

import java.util.Objects;
import javax.swing.tree.DefaultMutableTreeNode;
import library.model.Genre;

/**
 * @author sad
 */
public class GenresTreeNode extends DefaultMutableTreeNode {

    private String id;
    private String name;

    public GenresTreeNode(String id, String name) {
        this.id = id;
        this.name = name;
    }

    public GenresTreeNode(Genre genre) {
        this(genre.getId(), genre.getName());
    }

    @Override
    public String toString() {
        return name;
    }

    public String getId() {
        return id;
    }
    
    

    @Override
    public int hashCode() {
        return id.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final GenresTreeNode other = (GenresTreeNode) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        return true;
    }
}
